﻿using MesBSW.BLL.Mes;
using MesBSW.DAL.RoleDB;
using System.Data.Entity;

namespace MesBSW.DAL.MesDB
{
    public class MesDB : DbContext
    {
        public MesDB() : base("name=MesDB")
        {
            
        }

        /// <summary>
        /// 语言种类表
        /// </summary>
        public virtual DbSet<LanguageInfo> LanguageInfos { get; set; }

        /// <summary>
        /// 多语言项目
        /// </summary>
        public virtual DbSet<LanguageItem> LanguageItems { get; set; }

        /// <summary>
        /// 多语言项目显示结果 
        /// </summary>
        public virtual DbSet<LanguageMulit> LanguageMulits { get; set; }

        /// <summary>
        /// 物料分类信息
        /// </summary>
        public  virtual DbSet<MatGroup> MatGroups { get; set; }

        /// <summary>
        /// 物料信息
        /// </summary>
        public virtual DbSet<MatInfo> MatInfos { get; set; }

        /// <summary>
        /// 站点信息
        /// </summary>
        public virtual DbSet<SiteInfo> SiteInfos { get; set; }

        /// <summary>
        /// 站点组别
        /// </summary>
        public virtual DbSet<SiteGroup> SiteGroups { get; set; }

        /// <summary>
        /// 站点与组别的内联关系
        /// </summary>
        public virtual DbSet<SiteInfoGroup> SiteInfoGroups { get; set; }

        /// <summary>
        /// 原始工单
        /// </summary>
        public virtual DbSet<SourceProdProcess> SourceProdProcesses { get; set; }

        /// <summary>
        /// 部门组织表
        /// </summary>
        public virtual DbSet<BaseDeptModel> BaseDeptModel { get; set; }

        /// <summary>
        /// 拆分后的工单
        /// </summary>
        public virtual DbSet<TargetProdProcess> TargetProdProcesses { get; set; }

        /// <summary>
        /// 工单与站点组绑定关系
        /// </summary>
        public virtual DbSet<ProdProcSite> ProdProcSites { get; set; }

        /// <summary>
        /// 工单的扫描记录
        /// </summary>
        public virtual DbSet<ProdProcScan> ProdProcScans { get; set; }

        /// <summary>
        /// 状态类别 
        /// </summary>
        public virtual DbSet<StatusType> StatusTypes { get; set; }

        /// <summary>
        /// 状态值
        /// </summary>
        public virtual DbSet<StatusInfo> StatusInfos { get; set; }

        /// <summary>
        /// 异常订单
        /// </summary>
        public virtual DbSet<ExcepOrder> ExcepOrder { get; set; }

        /// <summary>
        /// 异常图片
        /// </summary>
        public virtual DbSet<ExcepPicture> ExcepPicture { get; set; }

        /// <summary>
        /// 异常图片
        /// </summary>
        public virtual DbSet<RepairReason> RepairReason { get; set; }

        /// <summary>
        /// 修改日志
        /// </summary>
        public virtual DbSet<MesLog> MesLogs { get; set; }

        /// <summary>
        /// 产品生产周期设定
        /// </summary>
        public virtual DbSet<ProdCycle> ProdCycle { get; set; }


        /// <summary>
        /// 原始工单生产周期设定
        /// </summary>
        public virtual DbSet<SourcePPCycle> SourcePPCycle { get; set; }

        ///// <summary>
        ///// 实际工单的生产周期
        ///// </summary>
        //public virtual DbSet<TargetPPCycle> TargetPPCycle { get; set; }

        ///// <summary>
        ///// 异常订单
        ///// </summary>
        //public virtual DbSet<ExcepOrder> ExcepOrder { get; set; }

        ///// <summary>
        ///// 用户表
        ///// </summary>
        //public virtual DbSet<BaseUserModel> BaseUserModel { get; set; }

        /// <summary>
        /// 用户站点分配
        /// </summary>
        public virtual DbSet<UserSite> UserSite { get; set; }

        ///// <summary>
        ///// 异常图片
        ///// </summary>
        //public virtual DbSet<ExcepPicture> ExcepPicture { get; set; }   

        ///// <summary>
        ///// 维修原因
        ///// </summary>
        //public virtual DbSet<RepairReason> RepairReason { get; set; }

        ///// <summary>
        ///// 检验单表头信息
        ///// </summary>
        //public virtual DbSet<InspectInfo> InspectInfo { get; set; }

        ///// <summary>
        ///// 检验单表体信息
        ///// </summary>
        //public virtual DbSet<InspectDetail> InspectDetail { get; set; }

        ///// <summary>
        ///// 维修单表头信息
        ///// </summary>
        //public virtual DbSet<RepairInfo> RepairInfo { get; set; }

        ///// <summary>
        ///// 维修单表体明细
        ///// </summary>
        //public virtual DbSet<RepairDetail> RepairDetail { get; set; }

        /// <summary>
        /// 生产线设定
        /// </summary>
        public virtual DbSet<ProdLineSetting> ProdLineSettings { get; set; }

        /// <summary>
        /// 工单的SMT点数
        /// </summary>
        public virtual DbSet<ProdPointSMT> ProdPointSMT { get; set; }


        //public virtual DbSet<MaterialTypeList> MaterialTypeList { get; set; }

        ///// <summary>
        ///// 工单借贷明细
        ///// </summary>
        //public virtual DbSet<ProdLendRepay> ProdLendRepays { get; set; }

        /// <summary>
        /// 生产线排程
        /// </summary>
        public virtual DbSet<ProdSchedule> ProdSchedules { get; set; }


        ///// <summary>
        ///// 生产线的标准数值
        ///// </summary>
        //public virtual DbSet<LineStandard> LineStandards { get; set; }

        ///// <summary>
        ///// 生产线的实际数值
        ///// </summary>
        //public virtual DbSet<LineReal> LineReals { get; set; }

        ///// <summary>
        ///// 物料进度和生产进度信息
        ///// </summary>
        //public virtual DbSet<ScanInfo> ScanInfo { get; set; }

        ///// <summary>
        ///// 生产线每天缺失工时说明
        ///// </summary>
        //public virtual DbSet<LineLossDetail> LineLossDetails { get; set; }

        ///// <summary>
        ///// 缺失工时原因信息表
        ///// </summary>
        //public virtual DbSet<LossReason> LossReasons { get; set; }

        ///// <summary>
        ///// 员工基本信息
        ///// </summary>
        //public virtual DbSet<EmplInfo> EmplInfos { get; set; }

        ///// <summary>
        ///// 员工出勤时数表
        ///// </summary>
        //public virtual DbSet<EmplAtt> EmplAtts { get; set; }

        ///// <summary>
        ///// 员工出勤时数明细表
        ///// </summary>
        //public virtual DbSet<EmplAttDetail> EmplAttDetails { get; set; }

        ///// <summary>
        ///// 考勤排程
        ///// </summary>
        //public virtual DbSet<AttSchedule> AttSchedules { get; set; }

        ///// <summary>
        ///// 员工借调记录
        ///// </summary>
        //public virtual DbSet<EmplLend> EmplLends { get; set; }

        ///// <summary>
        ///// 生产用料清单计划排单数量
        ///// </summary>
        //public virtual DbSet<SiteMaterialControlLockstockRecord> SiteMaterialControlLockstockRecord { get; set; }


        protected override void OnModelCreating(DbModelBuilder modelBuilder)
        {
            modelBuilder.Entity<MatInfo>().Property(e => e.board_qty).HasPrecision(18,5);

            modelBuilder.Entity<SourceProdProcess>().Property(e => e.OrderQty).HasPrecision(18, 5);
            modelBuilder.Entity<SourceProdProcess>().Property(e => e.GoodsLength).HasPrecision(18, 5);

            modelBuilder.Entity<TargetProdProcess>().Property(e => e.OrderQty).HasPrecision(18, 5);
            modelBuilder.Entity<TargetProdProcess>().Property(e => e.GoodsLength).HasPrecision(18, 5);
            modelBuilder.Entity<TargetProdProcess>().Property(e => e.ProdQty).HasPrecision(18, 5);

            modelBuilder.Entity<ProdProcScan>().Property(e => e.ScanQty).HasPrecision(18, 5);

            //modelBuilder.Entity<EmplLend>().Property(e => e.AttTime).HasPrecision(18,5);
            //modelBuilder.Entity<EmplAttDetail>().Property(e => e.AttTime).HasPrecision(18, 5);

            //modelBuilder.Entity<EmplAtt>().Property(e => e.AttTime).HasPrecision(18, 5);

            //modelBuilder.Entity<LineLossDetail>().Property(e => e.LossTime).HasPrecision(18, 5);

            //modelBuilder.Entity<LineReal>().Property(e => e.RealWorkTime).HasPrecision(18, 5);
            //modelBuilder.Entity<LineReal>().Property(e => e.RealTotalUpph).HasPrecision(18, 5);
            //modelBuilder.Entity<LineReal>().Property(e => e.EnaredWorkTime).HasPrecision(18, 5);
            //modelBuilder.Entity<LineReal>().Property(e => e.LossWorkTime).HasPrecision(18, 5);

            //modelBuilder.Entity<LineStandard>().Property(e => e.WorkTime).HasPrecision(18, 5);
            //modelBuilder.Entity<LineStandard>().Property(e => e.Upph).HasPrecision(18, 5);
            //modelBuilder.Entity<LineStandard>().Property(e => e.TotalUpph).HasPrecision(18, 5);

            //modelBuilder.Entity<ProdLineSetting>().Property(e => e.StaUpph).HasPrecision(18, 5);

            //modelBuilder.Entity<ProdLendRepay>().Property(e => e.LendRepayQty).HasPrecision(18, 5);

            //modelBuilder.Entity<ProdPointSMT>().Property(e => e.OrderQty).HasPrecision(18, 5);
            //modelBuilder.Entity<ProdPointSMT>().Property(e => e.PointPCB).HasPrecision(18, 5);
            //modelBuilder.Entity<ProdPointSMT>().Property(e => e.PointUnit).HasPrecision(18, 5);
            //modelBuilder.Entity<ProdPointSMT>().Property(e => e.PointTotal).HasPrecision(18, 5);



            //modelBuilder.Entity<SourcePPCycle>().Property(e => e.OrderQty).HasPrecision(18, 5);

            //modelBuilder.Entity<InspectInfo>().Property(e => e.ProdQty).HasPrecision(18, 5);
            //modelBuilder.Entity<InspectInfo>().Property(e => e.InspectQty).HasPrecision(18, 5);
            //modelBuilder.Entity<InspectInfo>().Property(e => e.PassQty).HasPrecision(18, 5);
            //modelBuilder.Entity<InspectInfo>().Property(e => e.FailQty).HasPrecision(18, 5);

            //modelBuilder.Entity<InspectDetail>().Property(e => e.FailQty).HasPrecision(18, 5);

            //modelBuilder.Entity<RepairInfo>().Property(e => e.TotalQty).HasPrecision(18, 5);

            //modelBuilder.Entity<RepairDetail>().Property(e => e.FailQty).HasPrecision(18, 5);
        }
    }
}
